package top.aiprogram.user.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import top.aiprogram.user.dao.StudentMapper;
import top.aiprogram.user.entity.Student;
import top.aiprogram.user.entity.Teacher;


/**
 * Created by HP on 2018/10/10.
 */
@Service
public class StudentServiceImpl implements StudentService{
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private TeacherService teacherService;
    @Transactional
//    @Override
    public int creatStudent(Student student) {
        int i = studentMapper.insertSelective(student);
        Teacher teacher=new Teacher();
        teacher.setTid(9);
        teacher.setUsername("老张");
        teacher.setPassword("laozhang");
        //嵌套事务查询
//        int i1 = teacherService.creatTeacher(teacher);
        return i;
    }
}
